 <%--
 *  File:   LendSlipSummary.jsp
 *  Desc:	the Lend slip summary page
 *
 *  Date		  Author		   Changes
 *  2011-6-20	  JackYin		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "A0112";
  String strTableName = "v_zylterminalpharmacybuy";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>
<%@ include file="/inc/Security.inc" %>
<html>
<head>
<title>TerminalPharmacyBuy</title>
<PageFlow:CheckPageFlow pageName="p_terminalpharmacybuysummary"/>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>
<%@ include file="/rpt/ReportURL.inc" %>
<%
HashMap userinfo = (HashMap)session.getAttribute("userinfo");
String  issalesman = (String) userinfo.get("issalesman");
String  username = (String) userinfo.get("employeename");
String flag = (String)pageContext.getAttribute("flag");
java.util.Calendar cal = java.util.Calendar.getInstance();   
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "TerminalPharmacyBuy.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function clickRow(obj,idx)
{
  var cform = document.cform;
  cform.radiorow[idx].checked=true;
  cform.orgid.value = eval('obj.all.orgid'+idx).value;
  cform.productid.value = eval('obj.all.productid'+idx).value;
  cform.year.value = eval('obj.all.year'+idx).value;
  cform.month.value = eval('obj.all.month'+idx).value;
}

function page_InBuyDetail()
{
	var year = cform.year.value;
	var month = document.cform.month.value;
	var productid = document.cform.productid.value;
	var orgid = document.cform.orgid.value;
	<%if(!"Y".equals(issalesman)){%>
    regionid = cform.regionid.value;
    userids = cform.userids.value;
	proviceofficecode = document.cform.proviceofficelist.value;
	businessareacode = document.cform.businessarealist.value;
	popup('PharmacyInBuyDetail.jsp?<%= OvalTools.randomURL() %>&partnerid='+orgid+'&productid='+productid+'&year='+year+'&month='+month +'&userids='+userids + '&proviceofficecode='+proviceofficecode + '&businessareacode='+businessareacode+'&regionid='+regionid+'&globalpccode=114','newwindow','height=400, width=1100,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
    <%}else{%>
	popup('PharmacyInBuyDetail.jsp?<%= OvalTools.randomURL() %>&partnerid='+orgid+'&productid='+productid+'&year='+year+'&month='+month+'&globalpccode=114','newwindow','height=500, width=1100,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}%>
	
}

function page_OutBuyDetail()
{
	var year = cform.year.value;
	var month = document.cform.month.value;
	var productid = document.cform.productid.value;
	var orgid = document.cform.orgid.value;
	<%if(!"Y".equals(issalesman)){%>
	 regionid = cform.regionid.value;
	    userids = cform.userids.value;
		proviceofficecode = document.cform.proviceofficelist.value;
		businessareacode = document.cform.businessarealist.value;
	popup('PharmacyOutBuyDetail.jsp?<%= OvalTools.randomURL() %>&partnerid='+orgid+'&productid='+productid+'&year='+year+'&month='+month +'&userids='+userids + '&proviceofficecode='+proviceofficecode + '&businessareacode='+businessareacode+'&regionid='+regionid+'&globalpccode=114','newwindow','height=400, width=1100,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}else{%>
	popup('PharmacyOutBuyDetail.jsp?<%= OvalTools.randomURL() %>&partnerid='+orgid+'&productid='+productid+'&year='+year+'&month='+month+'&globalpccode=114','newwindow','height=500, width=1100,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}%>
}


//salesman
function popRep() {
	var regionid=cform.regionid.value;
	var proviceofficecode = document.cform.proviceofficelist.value;
	var businessareacode = document.cform.businessarealist.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid+"&proviceofficecode="+proviceofficecode+"&businessareacode="+businessareacode;
  
	popwindow = window.open(url, "newwindow", status);
  }

function SetSalesMan(id,code,name){
	cform.userids.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

//getsecond 
function page_getpriviceoffice(){
	var objdeptcode=eval("cform.regionid");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , objdeptcode.value , "Integer");
	datahandler.getResultFromVector("resultproviceoffice","proviceofficename","proviceofficecode","document.cform.proviceofficelist");
	datahandler.add_job("j_terminalpharmacybuysummary");
	datahandler.runDataHandler();
  }



function page_getbusinessarea(){
	var objdeptcode=eval("cform.proviceofficelist");
	var regionid = document.cform.regionid.value;
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("regionid" , regionid , "Integer");
	datahandler.add_params("proviceofficelist" , objdeptcode.value , "String");
	datahandler.getResultFromVector("resultbusinessarea","businessareaname","businessareacode","document.cform.businessarealist");
	datahandler.add_job("j_terminalpharmacybuysummary");
	datahandler.runDataHandler();
 }


function page_excel(){
	var id = document.cform.userid.value;	
	var year =document.cform.years.value;
	var month =document.cform.months.value;
	var url ="";
	<%if(!"Y".equals(issalesman)){%>
	var proviceofficecode = document.cform.proviceofficelist.value;
	var businessareacode = document.cform.businessarealist.value;
	var userids =document.cform.userids.value;
	var regionid= document.cform.regionid.value;
  	 //window.location.href = "<%= reportURL %>/servlet/ExcecuteReport/PharmacyBuyInfo.sox?__folder=/ovalreport&rownum=2&employeeid="+ id+"&parentareaid="+regionid+"&areacode="+proviceofficecode+"&areacode1="+businessareacode+"&employeeids="+userids+"&year="+year+"&month="+month;	
  	url = "<%= reportURL %>/servlet/ExcecuteReport/PharmacyBuyInfo.sox?__folder=/ovalreport&rownum=2&employeeid="+ id+"&parentareaid="+regionid+"&areacode="+proviceofficecode+"&areacode1="+businessareacode+"&employeeids="+userids+"&year="+year+"&month="+month;
	<% }else{  %>
	var salesman =document.cform.userid.value;
  		 //window.location.href = "<%= reportURL %>/servlet/ExcecuteReport/PharmacyBuyInfo.sox?__folder=/ovalreport&rownum=2&employeeid="+ id+"&year="+year+"&month="+month+"&salesman="+salesman;
    url= "<%= reportURL %>/servlet/ExcecuteReport/PharmacyBuyInfo.sox?__folder=/ovalreport&rownum=2&employeeid="+ id+"&year="+year+"&month="+month+"&salesman="+salesman;
  	<% }%>
  	DataReport(url);
 }


function checkBoxSeleceed(){
	var obj =document.getElementsByName("deleteids");
	var objLen = obj.length;
	var j=0;
	var m=0;
	for (j==0;j<objLen;j++){
       if(obj[j].checked==true){
           m++;
       }
	}
	return m;
}

</script>

<style type="text/css">
*{padding:0;margin:0;}
.container {width:230px;margin:1px auto;}
.holder2 {color:#FDFAC5;}
/*wu tu yuan jiao*/
.b1 {height:1px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; margin:0 5px;background-color:#FDFAC5}
.b2 {height:1px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; border-right:2px solid #FDFAC5; border-left:2px solid #FDFAC5; margin:0 3px;background-color:#FDFAC5}
.b3 {height:1px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; border-right:1px solid #FDFAC5; border-left:1px solid #FDFAC5; margin:0 2px;background-color:#FDFAC5}
.b4 {height:2px; font-size:1px; overflow:hidden; display:block; background:#FDFAC5; border-right:1px solid #FDFAC5; border-left:1px solid #FDFAC5; margin:0 1px;background-color:#FDFAC5}
.content {border-right:1px solid #FDFAC5; height:15px;border-left:1px solid #FDFAC5;background-color:#FDFAC5}
</style>
</head>

<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_terminalpharmacybuysummary">
    <input type="hidden" name="actionname">
<custom:hidden property="userid" name="userinfo" scope="session"></custom:hidden>
<%--  page location   --%>
    <%@ include file="/inc/PageLocation.inc" %>
<custom:hidden property="globalpccode" ></custom:hidden>
    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
<%--  search criteria  --%>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0">
           <tr>
          <td class="summary_top" width="10%" colspan="3"></td>
          </tr>
           <%@ include file="/inc/SummarySearch.inc" %>
          </table>
        </td>
      </tr>
      	<tr>
        <td>
  <table width="1000" border="0" cellspacing="0" >
  <tr>
  <%
                  String year = cal.get(Calendar.YEAR)+"";     
					String month = cal.get(Calendar.MONTH)+"";
					if(cal.get(Calendar.MONTH) == 0){
						month = "12";
						year = (cal.get(Calendar.YEAR)-1)+"";
					}  
					if("first".equals(flag)){ 
				%>
	        	<td style="width:40px;" class="td_right" ><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="years" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1"/></td>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="months" dictType="Months" command="notnull" value="<%=month %>" label="L_Month"/></td>
	        	 	<td colspan="5"> 
	        	<div class="container">
                   <div class="holder">
                     <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
                       <div class="content">
                           <p>&nbsp;&nbsp;&nbsp;&nbsp;<font size="3"><b><%=label.getLabelName("L_TIP_SPAN") %></b></font>&nbsp;:&nbsp;&nbsp;<%=label.getLabelName("L_TIP_SPAN_VIEW") %></p>
                       </div>
                       <b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b>
                      </div>
                  </div>
	        	</td>
	        	<%}else{ %>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="years" dictType="Years" command="notnull" label="L_Year1"/></td>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="months" dictType="Months" command="notnull" label="L_Month"/></td>
	        	   	<td colspan="5"> 
	        	<div class="container">
                   <div class="holder">
                     <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
                       <div class="content">
                           <p>&nbsp;&nbsp;&nbsp;&nbsp;<font size="3"><b><%=label.getLabelName("L_TIP_SPAN") %></b></font>&nbsp;:&nbsp;&nbsp;<%=label.getLabelName("L_TIP_SPAN_VIEW") %></p>
                       </div>
                       <b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b>
                      </div>
                  </div>
	        	</td>
	        	    <%
	        	    }
			        %>
                    </tr>
        	     <% 
	                if("Y".equals(issalesman)){
	             %> 
	                  <tr>
	                <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:60px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:60px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               </tr>
	                <%}else{ %>
        	    <tr>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_Businessarea") +  label.getLabelName("L_Colon") %></td>
        	  	<td style="width:160px;" class="td_left"><custom:select property="regionid" optionInnerTextKey="regionname" style="width:160px" optionsName="resultregion" optionValueKey="regionid" onchange="page_getpriviceoffice()" defaultValue="ALL" defaultValueCost=""/></td>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_ProvinceOffice") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;" class="td_left">
					<custom:select property="proviceofficelist" optionInnerTextKey="proviceofficename" optionsName="resultproviceoffice" optionValueKey="proviceofficecode" defaultValue="----------" style="width:150px" defaultValueCost="" onchange="page_getbusinessarea();"/>
		        </td>
			    <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessAreaName") +  label.getLabelName("L_Colon") %></td>
				<td style="width:180px;" class="td_left">
				<custom:select property="businessarealist" optionInnerTextKey="businessareaname" optionsName="resultbusinessarea" optionValueKey="businessareacode" defaultValue="----------" style="width:180px" defaultValueCost=""/> </td>
        	     <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessContact") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;">
			<custom:text property="employeename" size="20" readonly="true" style="border:1px #7F9DB9 solid;"/>
			<a onClick="javascript:popRep();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> 
			<custom:hidden property="userids"/>
			<custom:hidden property="employeecode"/>
		   </td>
				<td style="20px;"><button type="reset" class="button1" name="re" value="clear"  style="width:60"><%=label.getLabelName("L_Clear") %></button></td>
			<%} %>
        	</tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table width="1600" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">




<tr class="deepblue-left">
<td rowspan="2" width="22">&nbsp;</td>
<td rowspan="2" width="70"><%=label.getLabelName("L_YearF")%></td>
<td rowspan="2" width="70"><%=label.getLabelName("L_Month")%></td>
<td rowspan="2" width="80"><%=label.getLabelName("L_PharmacyCode")%></td>
<td rowspan="2" width="400"><%=label.getLabelName("L_PharmacyName")%></td>
<td rowspan="2" width="90"><%=label.getLabelName("L_ProdCode")%></td>
<td rowspan="2" width="200"><%=label.getLabelName("L_ProdName")%></td>
<td rowspan="2" width="90"><%=label.getLabelName("L_FolwQty")%></td>

<td colspan="4"> <center><%=label.getLabelName("L_NotFolwQty")%> </center></td>

<td rowspan="2" width="90"><%=label.getLabelName("L_PurchasesQtySum")%></td>
<td rowspan="2" width="90"><%=label.getLabelName("L_PurchasesMoneySum")%></td>
<td rowspan="2" width="150"><%=label.getLabelName("L_Businessarea")%></td>
<td rowspan="2" width="250"><%=label.getLabelName("L_BusinessAreaName")%></td>
<td rowspan="2" width="100"><%=label.getLabelName("L_EmployeeName")%></td>
<td rowspan="2" width="100"><%=label.getLabelName("L_ManegerNameMN")%></td>
<td rowspan="2" width="180"><%=label.getLabelName("L_ProductGroupName")%></td>
</tr>

<tr height="30" class="deepblue-left">
<td width="80"><%=label.getLabelName("L_CHuanGoods")%></td>
<td width="80"><%=label.getLabelName("L_FANLiuXiang")%></td>
<td  width="80"><%=label.getLabelName("L_OThersTYpe")%></td>
<td  width="80"><%=label.getLabelName("L_NotFolwQtySum")%></td>
</tr>

 <%
     ArrayList detailTdArray = new ArrayList();
     detailTdArray.add(new RadioTD());
     detailTdArray.add(new WriteTD("year"));
     detailTdArray.add(new WriteTD("month"));
     detailTdArray.add(new WriteTD("orgcode"));
     detailTdArray.add(new WriteTD("orgname"));
     detailTdArray.add(new WriteTD("itemcode"));
     detailTdArray.add(new WriteTD("itemname"));
     detailTdArray.add(new WriteTD("lxqty"));
     detailTdArray.add(new WriteTD("chqty"));
     detailTdArray.add(new WriteTD("flxqty"));
     detailTdArray.add(new WriteTD("qtqty"));
	 detailTdArray.add(new WriteTD("notflowqty"));
     detailTdArray.add(new WriteTD("totalqty"));
     detailTdArray.add(new WriteTD("totalamount"));
     detailTdArray.add(new WriteTD("area1name"));
     detailTdArray.add(new WriteTD("area3name"));
     detailTdArray.add(new WriteTD("salesrepname"));
     detailTdArray.add(new WriteTD("parentsalesrepname"));
     detailTdArray.add(new WriteTD("productgroupname"));
     
     
     
     ArrayList hiddenArray = new ArrayList();
     hiddenArray.add(new HiddenInput("year",true));
     hiddenArray.add(new HiddenInput("month",true));
     hiddenArray.add(new HiddenInput("orgid",true));
     hiddenArray.add(new HiddenInput("productid",true));
 %>
    <custom:iteratetr tdArray="<%=detailTdArray%>" hiddenArray="<%=hiddenArray%>"  dataSource="totalsummary"/>
            <tr> 
	          <td colspan="7" style="text-align:right"><%=label.getLabelName("L_PageSum") +  label.getLabelName("L_Colon")%></td>
				<td class="red"><b><custom:write name="sumhash" property="sumlxqty" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="sumchqty" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="sumflxqty" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="sumqtqty" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="notflowsumqty" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="sumqty" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="sumamount" nbsp="true"/></b></td>
				<td colspan="5">&nbsp;</td>
	        </tr>
	        <tr> 
	          <td colspan="7" style="text-align:right"><%=label.getLabelName("L_TotalSum") +  label.getLabelName("L_Colon")%></td>
				
				<td class="red"><b><custom:write name="sumhash" property="pharmacybuylxqty" nbsp="true" dataType="number" dataFormatName="qtyviewformat" /></b></td>
				<td class="red"><b><custom:write name="sumhash" property="pharmacybuychqty"   dataType="number" dataFormatName="qtyviewformat" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="pharmacybuyflxqty" nbsp="true" dataType="number" dataFormatName="qtyviewformat" /></b></td>
				<td class="red"><b><custom:write name="sumhash" property="pharmacybuyqtqty"   dataType="number" dataFormatName="qtyviewformat" nbsp="true"/></b></td>
				<td class="red"><b><custom:write name="sumhash" property="notflowsumqtyall" nbsp="true" dataType="number" dataFormatName="qtyviewformat" /></b></td>
				<td class="red"><b><custom:write name="sumhash" property="pharmacybuytotalqty" nbsp="true" dataType="number" dataFormatName="qtyviewformat" /></b></td>
				<td class="red"><b><custom:write name="sumhash" property="pharmacybuytotalamount"   dataType="number" dataFormatName="amountviewformat" nbsp="true"/></b></td>
	         
	         <td colspan="5">&nbsp;</td>
	         <%@ include file="/inc/SummaryAction.inc" %>
	        </tr>

          </table>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
                   <td class="td_center">
              	<%if(pageContext.getAttribute("totalsummary")!=null){%>

              	<a onclick="page_excel();"><custom:button type="1" label="L_ExcelE" imgsrc="Modify.gif" border="0" style="width:100"/></a>&nbsp;&nbsp;
              <% if(!"Y".equals(issalesman)){ %>
                <a onclick="page_InBuyDetail();"><custom:button type="1" label="L_CheckInBuyDetail" imgsrc="Modify.gif" border="0" style="width:100"/></a>&nbsp;&nbsp;
               <%} %>
                <a onclick="page_OutBuyDetail();"><custom:button type="1" label="L_CheckOutBuyDetail" imgsrc="delete.gif" border="0" style="width:100"/></a>&nbsp;&nbsp;

            <%} %>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</body>
</html>

